﻿package net.wangit.view.chart.util;

import org.jfree.chart.axis.CategoryAnchor;
import org.jfree.chart.axis.CategoryLabelPositions;
import org.jfree.ui.RectangleEdge;

public class PositionUtil {

	public PositionUtil() {
	}

	public static final RectangleEdge getTitlePosition(int position) {
		switch (position) {
		case 1: // '\001'
			return RectangleEdge.TOP;

		case 2: // '\002'
			return RectangleEdge.LEFT;

		case 3: // '\003'
			return RectangleEdge.BOTTOM;

		case 4: // '\004'
			return RectangleEdge.RIGHT;
		}
		throw new UnsupportedOperationException((new StringBuilder(
				"Unsupported TitlePosition: ")).append(position).toString());
	}

	public static final CategoryAnchor getDomainGridlinePosition(int position) {
		switch (position) {
		case 3: // '\003'
			return CategoryAnchor.END;

		case 2: // '\002'
			return CategoryAnchor.MIDDLE;

		case 1: // '\001'
			return CategoryAnchor.START;
		}
		throw new UnsupportedOperationException((new StringBuilder(
				"Unsupported GridlinePosition: ")).append(position).toString());
	}

	public static final CategoryLabelPositions getCategoryLabelPositions(
			int position) {
		switch (position) {
		case 1: // '\001'
			return CategoryLabelPositions.STANDARD;

		case 2: // '\002'
			return CategoryLabelPositions.UP_45;

		case 3: // '\003'
			return CategoryLabelPositions.UP_90;

		case 4: // '\004'
			return CategoryLabelPositions.DOWN_45;

		case 5: // '\005'
			return CategoryLabelPositions.DOWN_90;
		}
		throw new UnsupportedOperationException((new StringBuilder(
				"Unsupported CategoryLabelPositions: ")).append(position)
				.toString());
	}
}
